#include <QApplication>
#include <QQmlApplicationEngine>
#include <QtQml>
#include "components/userhandle.h"


int main(int argc, char *argv[])
{
    userHandle *myHandle = new userHandle();
    QApplication app(argc, argv);

    QQmlApplicationEngine engine;
    const QUrl url(u"qrc:/opencvTeachTool/main.qml"_qs);
    QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                     &app, [url](QObject *obj, const QUrl &objUrl) {
        if (!obj && url == objUrl)
            QCoreApplication::exit(-1);
    }, Qt::QueuedConnection);

    engine.rootContext()->setContextProperty("myHandle", myHandle);
    engine.addImageProvider("camera", myHandle->getImageProvider()); // 绑定路径名和回调函数(Image组件使用此路径时会触发回调函数用以显示回调函数返回的图片)

    engine.load(url);

    return app.exec();
}
